<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\Access;
use Illuminate\Routing\Router;

class AccessController extends Controller
{

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function home(Request $request)
    {
        $routes = collect(app('router')->getRoutes())->map(function ($route) {
			return [
				'host'   => $route->domain(),
				'method' => implode('|', $route->methods()),
				'path'    => $route->uri(),
				'code'   => $route->getName(),
				'action' => ltrim($route->getActionName(), '\\'),
				'middleware' => $this->getMiddleware($route),
			];
        })->all();
		
		$data['code']=0;
		$data['data']=Access::get();
		$data['error']="";
		$data['msg']="success";
		$data['timestamp']=time();
		return $data;
    }
}
